]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Add shell_texture_cache_load_from_name
authorColin Walters <walters@verbum.org>
Thu, 30 Jul 2009 04:17:25 +0000 (00:17 -0400)
committerColin Walters <walters@verbum.org>
Sun, 9 Aug 2009 13:53:05 +0000 (09:53 -0400)
Utility function to load a texture for a themed icon from a
string name.

src/shell-texture-cache.c
src/shell-texture-cache.h

index 1b3a8d7f1ca083f1d5c7df5e42709d124b41be05..60fade11d32205f0011d3af88d8cefad0dcebc29 100644 (file)
@@ -8,12 +8,12 @@ typedef struct
 {
   ShellTextureCachePolicy policy;
 
-  /* These 3 are exclusive */
+  /* These are exclusive */
   GIcon *icon;
   gchar *uri;
   gchar *thumbnail_uri;
 
-  /* This one is common to all 3 */
+  /* This one is common to all */
   guint size;
 } CacheKey;
 
@@ -32,14 +32,17 @@ static guint
 cache_key_hash (gconstpointer a)
 {
   CacheKey *akey = (CacheKey *)a;
+  guint base_hash;
 
   if (akey->icon)
-    return g_icon_hash (akey->icon) + 31*akey->size;
+    base_hash = g_icon_hash (akey->icon);
   else if (akey->uri)
-    return g_str_hash (akey->uri) + 31*akey->size;
+    base_hash = g_str_hash (akey->uri);
   else if (akey->thumbnail_uri)
-    return g_str_hash (akey->thumbnail_uri) + 31*akey->size;
-  g_assert_not_reached ();
+    base_hash = g_str_hash (akey->thumbnail_uri);
+  else
+    g_assert_not_reached ();
+  return base_hash + 31*akey->size;
 }
 
 static gboolean
@@ -772,6 +775,31 @@ shell_texture_cache_load_gicon (ShellTextureCache *cache,
   return CLUTTER_ACTOR (texture);
 }
 
+/**
+ * shell_texture_cache_load_icon_name:
+ * @cache: The texture cache instance
+ * @name: Name of a themed icon
+ * @size: Size of themed
+ *
+ * Load a themed icon into a texture.
+ *
+ * Return Value: (transfer none): A new #ClutterTexture for the icon
+ */
+ClutterActor *
+shell_texture_cache_load_icon_name (ShellTextureCache *cache,
+                                    const char        *name,
+                                    gint               size)
+{
+  ClutterActor *texture;
+  GIcon *themed;
+
+  themed = g_themed_icon_new (name);
+  texture = shell_texture_cache_load_gicon (cache, themed, size);
+  g_object_unref (themed);
+
+  return CLUTTER_ACTOR (texture);
+}
+
 /**
  * shell_texture_cache_load_uri:
  *
index d24a681285504352d529924366d2628ac4f2911e..a228fbae86d6b23129c7a0c531d8b435da720d4d 100644 (file)
@@ -40,6 +40,10 @@ GType shell_texture_cache_get_type (void) G_GNUC_CONST;
 
 ShellTextureCache* shell_texture_cache_get_default (void);
 
+ClutterActor *shell_texture_cache_load_icon_name (ShellTextureCache *cache,
+                                                  const char        *name,
+                                                  gint               size);
+
 ClutterActor *shell_texture_cache_load_gicon (ShellTextureCache *cache,
                                               GIcon             *icon,
                                               gint               size);